/* **********************************************************************************
 *
 * Copyright (c) Ascend.NET Project. All rights reserved.
 *
 * This source code is subject to terms and conditions of the Shared Source License
 * for Ascend. A copy of the license can be found in the License.html file
 * at the root of this distribution. If you can not locate the Shared Source License
 * for Ascend, please send an email to ascend_adm@hotmail.com.
 * By using this source code in any fashion, you are agreeing to be bound by
 * the terms of the Shared Source License for Ascend.NET.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * **********************************************************************************/

using Ascend.Resources;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Ascend.Windows.Forms
{
    /// <summary>
    /// Provides the base class for types that define a list of items used to create a DesignerActionPanel.
    /// </summary>
    class NavigationPanePageActionList : DesignerActionList
    {
        private NavigationPanePage _navigationPanePage;

        /// <summary>
        /// Initializes a new instance of the NavigationPanePageActionList class.
        /// </summary>
        /// <param name="navigationPanePage">A NavigationPanePage component.</param>
        public NavigationPanePageActionList(NavigationPanePage navigationPanePage) : base(navigationPanePage)
        {
            this._navigationPanePage = navigationPanePage;

        }

        /// <summary>
        /// The font associated with the control.
        /// </summary>
        /// <value>
        /// <para>
        /// System.Drawing.Font . The base font to be inherited by child controls.
        /// </para>
        /// <para>
        /// This property is read/write.
        /// </para>
        /// </value>
        public Font Font
        {
            get
            {
                return this._navigationPanePage.Font;

            }

            set
            {
                this.GetPropertyByName("Font").SetValue(this._navigationPanePage, value);

            }

        }

        /// <summary>
        /// The text associated with the control.
        /// </summary>
        /// <value>
        /// <para>
        /// System.String .
        /// </para>
        /// <para>
        /// This property is read/write.
        /// </para>
        /// </value>
        public string Text
        {
            get
            {
                return (string)this._navigationPanePage.Text;

            }

            set
            {
                this.GetPropertyByName("Text").SetValue(this._navigationPanePage, value);

            }

        }

        /// <summary>
        /// The ContentAlignment associated with this controls text.
        /// </summary>
        /// <value>
        /// <para>
        /// System.Drawing.ContentAlignment . The ContentAlignment associated with this controls text.
        /// </para>
        /// <para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        public ContentAlignment TextAlign
        {
            get
            {
                return this._navigationPanePage.TextAlign;

            }

            set
            {
                this.GetPropertyByName("TextAlign").SetValue(this._navigationPanePage, value);

            }

        }

        /// <summary>
        /// The image associated with the control.
        /// </summary>
        /// <value>
        /// Image
        /// </value>
        public Image Image
        {
            get
            {
                return (Image)this._navigationPanePage.Image;

            }

            set
            {
                if (value != null && value.ToString() == "(none)")
                {
                    return;

                }

                this.GetPropertyByName("Image").SetValue(this._navigationPanePage, value);

            }

        }

        /// <summary>
        /// The ContentAlignment associated with this controls image.
        /// </summary>
        /// <value>
        /// <para>
        /// System.Drawing.ContentAlignment . The ContentAlignment associated with this controls image.
        /// </para>
        /// <para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        public ContentAlignment ImageAlign
        {
            get
            {
                return this._navigationPanePage.ImageAlign;

            }

            set
            {
                this.GetPropertyByName("ImageAlign").SetValue(this._navigationPanePage, value);

            }

        }

        /// <summary>
        /// Gets or sets the name of the control.
        /// </summary>
        /// <value>
        /// <para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        public string Name
        {
            get
            {
                return this._navigationPanePage.Name;

            }

            set
            {
                this.GetPropertyByName("Name").SetValue(this._navigationPanePage, value);

            }

        }

        /// <summary>
        /// Returns a property descriptor for the passed property name.
        /// </summary>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The property descriptor.</returns>
        private PropertyDescriptor GetPropertyByName(string propertyName)
        {
            PropertyDescriptor propertyDescriptor;

            propertyDescriptor = TypeDescriptor.GetProperties(this._navigationPanePage)[propertyName];

            if (propertyDescriptor == null)
            {
                throw new ArgumentException(ResourceText.GetLocalizedString("NPPPropertyNotFoundExceptionText"));

            }
            else
            {
                return propertyDescriptor;

            }

        }

        /// <summary>
        /// Returns the collection of DesignerActionItem objects contained in the list. 
        /// </summary>
        /// <returns>A DesignerActionItem array that contains the items in this list.</returns>
        public override DesignerActionItemCollection GetSortedActionItems()
        {
            DesignerActionItemCollection items = new DesignerActionItemCollection();

            items.Add(new DesignerActionPropertyItem("Name", ResourceText.GetLocalizedString("ActionListDisplayNameName"), "Design", ResourceText.GetLocalizedString("NameDescription")));

            items.Add(new DesignerActionHeaderItem(ResourceText.GetLocalizedString("ActionListAppearanceCategory"), "Appearance"));
            items.Add(new DesignerActionTextItem(ResourceText.GetLocalizedString("ActionListAppearanceTextItem"), "Appearance"));
            items.Add(new DesignerActionPropertyItem("Font", ResourceText.GetLocalizedString("ActionListDisplayNameFont"), "Appearance", ResourceText.GetLocalizedString("FontDescription")));
            items.Add(new DesignerActionPropertyItem("Image", ResourceText.GetLocalizedString("ActionListDisplayNameImage"), "Appearance", ResourceText.GetLocalizedString("ImageDescription")));
            items.Add(new DesignerActionPropertyItem("ImageAlign", ResourceText.GetLocalizedString("ActionListDisplayNameImageAlign"), "Appearance", ResourceText.GetLocalizedString("ImageAlignmentDescription")));
            items.Add(new DesignerActionPropertyItem("Text", ResourceText.GetLocalizedString("ActionListDisplayNameText"), "Appearance", ResourceText.GetLocalizedString("TextDescription")));
            items.Add(new DesignerActionPropertyItem("TextAlign", ResourceText.GetLocalizedString("ActionListDisplayNameTextAlign"), "Appearance", ResourceText.GetLocalizedString("TextAlignmentDescription")));

            return items;

        }

    }

}
